package com.hey.baseapplication.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.hey.baseapplication.R;
import com.hey.baseapplication.utils.SPUtil;
import com.hey.baseapplication.view.BaseView;

import java.util.concurrent.TimeUnit;

import rx.Observable;
import rx.functions.Action1;

public class WelcomeActivity extends AppCompatActivity implements BaseView{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        next();
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void next() {
       if(SPUtil.instance.getLogin(this)){
           Observable.timer(2, TimeUnit.SECONDS).subscribe(new Action1<Long>() {
               @Override
               public void call(Long aLong) {
                   Intent intent=new Intent(WelcomeActivity.this,MainActivity.class);
                   startActivity(intent);
                   finish();
               }
           });
       }else{
           Observable.timer(2, TimeUnit.SECONDS).subscribe(new Action1<Long>() {
               @Override
               public void call(Long aLong) {
                   Intent intent=new Intent(WelcomeActivity.this,LoginActivity.class);
                   startActivity(intent);
                   finish();
               }
           });
       }

    }
}
